package cn.tedu.serializable;

import java.io.Serializable;

/**
 * @author ：Dsi
 * @date ：2021/11/17 10:23
 * Describe ：该类用于封装学生类
 */
/*该类需要被序列化时，需要实现Serializable类，该类没有任何方法
  仅表示该类可以被序列化
 */
public class Student implements Serializable {
    /*将UID写死，后面再更改该类时，仍可以反序列化成功
     *序列化与反序列化时，会比较UID，一致时才反序列化成功
     */
    private static final long serialVersionUID = 1l;

    private String name;
    private int age;
    private String addr;
    private  char gender;
    private  int a;
    {
        System.out.println("构造方法");
    }
    public Student(){
        System.out.println("无参构造");
    }

    public Student(String name, int age, String addr, char gender) {
        super();
        this.name = name;
        this.age = age;
        this.addr = addr;
        this.gender = gender;
        System.out.println("全参构造");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", addr='" + addr + '\'' +
                ", gender=" + gender +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public static void main(String[] args) {

    }

}
